package com.yueya.media.mongo;

import com.mongodb.gridfs.GridFSDBFile;
import org.springframework.stereotype.Component;

import java.io.InputStream;
import java.util.List;
import java.util.Map;

@Component
public interface IGridFsDao {
    /**
     * 元信息（元信息可以为null）<br>
     * 元信息请使用这种格式：<br>
     * metaData.put("caseType", "0/1/2/3");<br>
     * metaData.put("uniqueId", "图片id");
     * metaData.put("taskId","采集编号");
     * @param id
     * @param in
     * @param fileName
     * @param extendName
     * @param metaData
     * @param bucket
     */
    void save(String id, InputStream in, String fileName, String extendName, Map<String, String> metaData, String bucket);

    /**
     * 根据Id查询图片
     */
    GridFSDBFile findById(String Id, String bucket);

    List<GridFSDBFile> findByMeta(Map<String, String> map, String bucket);

    List<GridFSDBFile> findByMainId(String mainId, String bucket);

    void deleteById(String id, String bucket);

    boolean updateMeta(String id, Map<String, Object> exts, String bucket);

    boolean deleteByMeta(Map<String, Object> exts, String bucket);

    InputStream getInputstream(String Id, String bucket);

    boolean deleteByMainId(String mainId, String bucket);
}
